package homework;

public class HomeWork25 {
    public ListNode partition(ListNode pHead, int x) {
        ListNode low=new ListNode(-1);
        ListNode high=new ListNode(-1);
        ListNode cur1=low;
        ListNode cur2=high;
        while (pHead!=null){
            if(pHead.val<x){
                cur1.next=pHead;
                cur1=cur1.next;
            }else {
                cur2.next=pHead;
                cur2=cur2.next;
            }
            pHead=pHead.next;
        }
        cur1.next=high.next;
        cur2.next=null;
        return low.next;
    }
}
